-
-
Notifications
You must be signed in to change notification settings - Fork 533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should I use it in production? #104
Comments
No, not really. In production you'd want to only be in transpile mode (you should have already type checked). If someone wants to contribute some PRs for this functionality, we can get it in. Otherwise I'd wait for #44. |
So @blakeembrey, can we now use it in production? As in $ ts-node -F server.ts I currently do |
Definitely your choice, go ahead 😄 There's no heavy overheads. |
using
|
That make sense to me. Fast mode isn’t using type information, it’s just plain transpiling files on the fly. That’s not equivalent to |
So, should I use in production? |
That's not something I can tell you. I can tell you that loading type information has a larger overhead, but it shouldn't impact performance (only memory once started). |
Hey, FYI there still no documentation mention about the |
It's the default behaviour. See https://github.com/TypeStrong/ts-node/releases/tag/v4.0.0. |
The release note mentions use --type-check for type checking behaviour, but its not mentioned again in the docs? |
That’s because it was three major releases ago and the behaviour was reverted. It confused other people to not type check by default. |
So the |
The same, yes. |
Because it's better to keep local dev and prod as close to eachother as possible to reduce the chance of prod bugs that can't be reproduced locally. Per TypeStrong/ts-node#104 it seems the main impact of using it in production is a slightly increased memory footprint.
Except its |
So, the summary of this thread is that "If i use ts-node server.ts in production, that is completely okay, as it is transpile only mode by default so dont need to pass --fast or --transpile-only flags. correct me if something is missed. |
https://github.com/TypeStrong/ts-node#cli-and-programmatic-options says |
That’s correct. There was a period of time it was the default for performance reasons, but I received a lot of issues because it differed from typescript. You’ll need the flag or use the register file for it. |
… altogether for resources package This should be fine as long as we use the -T mode https://github.com/TypeStrong/ts-node/issues/104\#issuecomment-504945372
So the new summary of this thread is: Go ahead and use ts-node in production; just set the Is that correct? |
For anyone wondering how to pass in
A little bit about In this mode, files are only transpiled without typechecking, greatly improving compilation speed. All this means is your console won't spit out TypeError warnings, but if you use VSCode you already get realtime warnings within the editor. |
A user early in this thread said that EDIT: It looks like this is still a problem according to #873 |
Yes, it’s not possible to get type information if your compiling without type information - which is what transpile only does. |
I haven't seen any issues with sequelize-typescript – the current limitation may be specifically limited to the enum issue described in #873. |
General query to this thread: Out of curiosity, what are the arguments for not using |
@iiian I don't think there is one, as long as you pass the correct flag disabling type checking. The one mentioned above may be outdated and I recommend you to check manual for the exact name. |
Thumbs up if you're using I am! 👍 Sad face if you're too afraid 😢 |
Thumbs up and sad face because going to production and afraid |
Same! Been migrating a node.js app to typescript. I tried running "tsc && node dist/app.js" but kept getting |
I deployed the other day and broke things :/ I build a video editor https://storycreatorapp.com and recently migrated my node server to TypeScript. The reason it broke is that I was trying to get it to work with pm2. Are you guys running your node.js servers in production without https://pm2.keymetrics.io/? That seems scary to me. Has anyone gotten it to work with pm2? |
@bluematter you'll probably have better luck in the TypeScript Community Discord: https://discord.com/invite/typescript |
It's an old topic but I want to share a code I wrote for testing purposes and its results. I wrote a simple function that calculates Fibonacci numbers for the code that uses both CPU and memory, and I print out the time required for the calculation and how much RAM it uses in that time, you can try it yourself. I am attaching the results below. It seems that there is not much difference in speed but there is a difference in memory usage and "--transpile-only" doesn't change much about it
|
We actually just faced an outage because of this as the max size of the heap in Node.js by default is 512mb. We were getting very close to it before, but we moved some packages around in our monorepo and that made Obviously we can increase the limit using |
@leventkaragol thanks for sharing your benchmark and results. node 18
node 20
Tests report the memory footprint is reduced significantly when using However, the most interesting result that tests report comes from Node20, when switching from CommonJS to ESM (by adding "type": "module" in You'll have to ditch the node 20 ESM
So, for this last test, it looks like the memory usage is not affected at all by the Hope this can be helpful to people researching on the same topic. |
I couldn't find any mention about it in the readme
The text was updated successfully, but these errors were encountered: